/*
 * @Author: wyf 844650674@qq.com
 * @Date: 2022-10-12 08:30:48
 * @LastEditors: wangyifei 844650674@qq.com
 * @LastEditTime: 2022-11-27 11:39:29
 * @FilePath: \sports\admin-server\model\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// 用户相关的数据模型
const mongoose = require("mongoose");

// 连接数据库
mongoose.connect("mongodb://localhost:27017/meiya3", {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

const db = mongoose.connection;

db.once("open", () => {
  console.log("数据库连接成功");
});

db.on("error", () => {
  console.log("数据库连接失败");
});

// 组织导出模型类
module.exports = {
  User: mongoose.model("User", require("./user")),
  Fun: mongoose.model("Fun", require("./fun")),
  Role: mongoose.model("Role", require("./role")),
  Comment: mongoose.model("Comment", require("./comment")),
  Thumbs: mongoose.model("Thumbs", require("./thumbs")),
  Like: mongoose.model("Like", require("./like")),
  Ticket: mongoose.model("Ticket", require("./ticket")),
};
